<?php 
$data['page_selected'] = 'home';
$this->load->view('constants/header', $data);?>

<script type="text/javascript">
	$(document).ready(function() {
		$.datepicker.regional['es'] = {
		closeText: 'Cerrar',
		prevText: '&#x3c;Ant',
		nextText: 'Sig&#x3e;',
		currentText: 'Hoy',
		monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
		monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
		'Jul','Ago','Sep','Oct','Nov','Dic'],
		dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
		dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Juv','Vie','S&aacute;b'],
		dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','S&aacute;'],
		weekHeader: 'Sm',
		dateFormat: 'dd/mm/yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['es']);
		
		$("#birthdate").datepicker({
			dateFormat: 'dd/mm/yy',
			changeMonth: true,
			changeYear: true,
			minDate: "-50Y", 
			maxDate: "+0"
			});
		
	});
	
	$(function() {
		var availableTags = new Array();
		<?php for($i=0; $i <  count($buddies) ; $i++){?>
			availableTags[<?php echo($i); ?>] = {label: "<?php echo($buddies[$i]['nombre'].' '.$buddies[$i]['apellido'].', CI:'.$buddies[$i]['ci_integrante']);?>",
												 value: "<?php echo($buddies[$i]['id_integrante']);?>"};
		<?php } ?>	
		
		$('#tags').autocomplete({
			minLength: 2,
			source: availableTags,
			focus: function(event, ui) {
				$('#tags').val(ui.item.label);
				return false;
			},
			select: function(event, ui) {
				$('#tags').val(ui.item.label);
				$('#id_buddy').val(ui.item.value);				
				return false;
			}
		});
	});
</script>
<div id="site_content">
	<?php 
		$this->load->view('constants/sidebar');  
		echo form_open(base_url().'user/signUp'); 
	?>
    <div id="content">
        <!-- insert the page content here -->
        <h1>Nuevo Integrante</h1>
        	<h2 style="font-size:10px"><img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp; Campos Obligatorios</h2>
            <table>
            	<tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Nombre </td>
                    <td> <input type="text" name="name" id="name" value="<?php echo set_value('name'); ?>"/> </td>
                    <td> <?php echo form_error('name'); ?> </td>
                </tr>
                <tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Apellido </td>
                    <td> <input type="text" name="lastname" id="lastname" value="<?php echo set_value('lastname'); ?>"/> </td>
                    <td> <?php echo form_error('lastname'); ?> </td>
                </tr>
                <tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;C.I. </td>
                    <td> <input type="text" name="ci" id="ci" value="<?php echo set_value('ci'); ?>"/> </td>
                    <td> <?php echo form_error('ci'); ?> </td>
                </tr>
                <tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;G&eacute;nero </td>
                    <td> 
                    	<input type="radio" name="genre" id="genre" value="m" checked="checked" <?php echo set_radio('genre', 'm'); ?>/>M &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                    	<input type="radio" name="genre" id="genre" value="f" <?php echo set_radio('genre', 'f'); ?>/>F 
                    </td>
                    <td></td>
                </tr>
                <tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Fecha de Nacimiento </td>
                    <td> <input type="text" name="birthdate" id="birthdate" readonly="readonly" value="<?php echo set_value('birthdate'); ?>"/> </td>
                    <td> <?php echo form_error('birthdate'); ?> </td>
                </tr>
                <tr>
                	<td> Tipo de discapacidad </td>
                    <td> 
                    	<select name="disability" id="disability"> 
                        	<option value="-" <?php echo set_select('disability', '-'); ?>>N/A</option>
                        	<?php foreach($disabilities as $d){ ?>
                            	<option value="<?php echo $d['cod_discapacidad'] ?>" <?php echo set_select('disability', $d['cod_discapacidad']); ?>>
									<?php echo $d['descripcion']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </td>
                    <td></td>
                </tr>
                <tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Tipo de Buddy </td>
                    <td> 
                    	<select name="buddy_type" id="buddy_type"> 
                        	<option value="-"  <?php echo set_select('buddy_type', '-'); ?>>-----</option>
                        	<?php foreach($buddy_types as $b){ ?>
                            	<option value="<?php echo $b['cod_tipo_buddy'] ?>" <?php echo set_select('buddy_type', $b['cod_tipo_buddy']); ?>>
									<?php echo $b['descripcion']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </td>
                    <td> <?php echo form_error('buddy_type'); ?> </td>
                </tr>
                <tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Club perteneciente </td>
                    <td> 
                    	<select name="id_club" id="id_club"> 
                        	<option value="-" <?php echo set_select('id_club', '-'); ?>>-----------</option>
                        	<?php foreach($clubs as $c){ ?>
                            	<option value="<?php echo $c['id_club'] ?>" <?php echo set_select('id_club', $c['id_club']); ?>>
									<?php echo $c['nombre']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </td>
                    <td> <?php echo form_error('id_club'); ?> </td>
                </tr>
                <tr>
                	<td> Buddy asignado </td>
                    <td> <input id="tags" /> <input type="hidden" name="id_buddy" id="id_buddy"/> </td>
                    <td></td>
                </tr>
                <tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Tel&eacute;fono Celular </td>
                    <td> <input type="text" name="celphone" id="celphone" value="<?php echo set_value('celphone'); ?>"/> </td>
                    <td> <?php echo form_error('celphone'); ?> </td>
                </tr>
                <tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Tel&eacute;fono de Habitaci&oacute;n </td>
                    <td> <input type="text" name="phone" id="phone" value="<?php echo set_value('phone'); ?>"/> </td>
                    <td> <?php echo form_error('phone'); ?> </td>
                </tr>
                <tr>
                	<td rowspan="7"> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Direcci&oacute;n </td>
                    <td> 
                    	<textarea name="address" id="address" cols="17" rows="6"><?php echo set_value('address'); ?></textarea>
                    </td>
                    <td>
                    	<?php echo form_error('address'); ?> 
                    </td>
                </tr>
                <tr>
                	<td>                        
                        <div class="formField" id="coS">
                        	<span class="InputValue" >
								<?php if (set_value('country') == "") {?> 
                                	Pa&iacute;s
                                <?php } ?>
                            </span>
                            <input type="text" name="country" id="country" onfocus="onFocusInput('co')" onblur="onBlurInput('country','co', 'Pa&iacute;s')" value="<?php echo set_value('country'); ?>" /> 
                        </div>
                    </td>
                    <td>
                    	<?php echo form_error('country'); ?>
                    </td>
                </tr>
                <tr>
                	<td>
                        <div class="formField" id="stS"> 
                        	<span class="InputValue" >
                            	<?php if (set_value('state') == "") {?> 
                                	Estado
                                <?php } ?>
                            </span>
                            <input type="text" name="state" id="state" onfocus="onFocusInput('st')" onblur="onBlurInput('state','st', 'Estado')" value="<?php echo set_value('state'); ?>"/> 
                        </div>
                   	</td>
                    <td>
                    	<?php echo form_error('state'); ?>
                    </td>
                </tr>
                <tr>
                	<td>
                        <div class="formField" id="muS">
                        	<span class="InputValue">
                            	<?php if (set_value('municipality') == "") {?> 
                                	Municipio
                                <?php } ?>
                            </span>
                            <input type="text" name="municipality" id="municipality" onfocus="onFocusInput('mu')" onblur="onBlurInput('municipality','mu', 'Municipio')" value="<?php echo set_value('municipality'); ?>"/>
                        </div>
                        </td>
                    <td>
                    	<?php echo form_error('municipality'); ?>
                    </td>
                </tr>
                <tr>
                	<td>
                        <div class="formField" id="paS"> 
                        	<span class="InputValue">
                            	<?php if (set_value('parish') == "") {?> 
                                	Parroquia
                                <?php } ?>
                            </span>
                            <input type="text" name="parish" id="parish" onfocus="onFocusInput('pa')" onblur="onBlurInput('parish','pa', 'Parroquia')" value="<?php echo set_value('parish'); ?>"/>
                        </div>
                        </td>
                    <td>
                    	<?php echo form_error('parish'); ?>
                    </td>
                </tr>
                <tr>
                	<td>
                        <div class="formField" id="avS"> 
                        	<span class="InputValue">
                            	<?php if (set_value('avenue') == "") {?> 
                                	Avenida
                                <?php } ?>
                            </span>
                            <input type="text" name="avenue" id="avenue" onfocus="onFocusInput('av')" onblur="onBlurInput('avenue','av', 'Avenida')" value="<?php echo set_value('avenue'); ?>"/>
                        </div>
                        </td>
                    <td>
                    	<?php echo form_error('avenue'); ?>
                    </td>
                </tr>
                <tr>
                	<td>
                        <div class="formField" id="strS"> 
                        	<span class="InputValue">
                            	<?php if (set_value('street') == "") {?> 
                                	Calle
                                <?php } ?>
                            </span>
                            <input type="text" name="street" id="street" onfocus="onFocusInput('str')" onblur="onBlurInput('street','str', 'Calle')" value="<?php echo set_value('street'); ?>"/>
                        </div>
                        </td>
                    <td>
                    	<?php echo form_error('street'); ?>
                    </td>
                </tr>
                <tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Direcci&oacute;n de correo electr&oacute;nico </td>
                    <td> <input type="text" name="email" id="email" value="<?php echo set_value('email'); ?>"/> </td>
                    <td> <?php echo form_error('email'); ?> </td>
                </tr>
                <tr>
                	<td> Seud&oacute;nimo de Twitter </td>
                    <td> <input type="text" name="twitter" id="twitter" value="<?php echo set_value('twitter'); ?>"/> </td>
                    <td> <?php echo form_error('twitter'); ?> </td>
                </tr>
                <tr>
                	<td> Facebook </td>
                    <td> <input type="text" name="facebook" id="facebook" value="<?php echo set_value('facebook'); ?>"/> </td>
                    <td> <?php echo form_error('facebook'); ?> </td>
                </tr>
                <tr>
                	<td> P&aacute;gina Web </td>
                    <td> <input type="text" name="webpage" id="webpage" value="<?php echo set_value('webpage'); ?>"/> </td>
                    <td> <?php echo form_error('webpage'); ?> </td>
                </tr>
                <tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Contrase&ntilde;a </td>
                    <td> <input type="password" name="password" id="password"/> </td>
                    <td> <?php echo form_error('password'); ?> </td>
                </tr>
                <tr>
                	<td> <img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp;Confirmar contrase&ntilde;a </td>
                    <td> <input type="password" name="passwordConf" id="passwordConf"/> </td>
                    <td> <?php echo form_error('passwordConf'); ?> </td>
                </tr>
                <tr>
                	<td colspan="3" align="right">
                    	<input type="submit" name="button" class="submit" value="Procesar" />
                    </td>
                </tr>
            </table>
            <h2 style="font-size:10px"><img src="<?php echo base_url().IMG; ?>icon_RequiredField.png">&nbsp; Campos Obligatorios</h2>
            
            
        </form>

    </div>
</div>
<script type="text/javascript">	
	function onFocusInput(divId){
		$('#'+divId+'S span').html("");
	}
	
	function onBlurInput(inputId, divId, value){
		if($('#'+inputId+'').val() == "")
			$('#'+divId+'S span').html(value);
		else
			$('#'+divId+'S span').html("");
	}
</script>
<?php $this->load->view('constants/footer'); ?>
